home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 2.iso / bin / installServer < prev    next >
Text File  |  1996-11-11  |  12KB  |  366 lines

  1. #!/bin/csh -f
  2.  
  3. set path = (/usr/bsd /bin /usr/bin /usr/sbin /usr/bin/X11)
  4. #
  5. # update path to also look in the same directory from where this script
  6. # was executed from
  7. #
  8.  
  9. set DT_xconfirm = "$DT_utilities/DT_xconfirm"
  10. set TLINK = "/usr/sbin/tlink"
  11.  
  12. set path = (${DT_util_path} $path)
  13.  
  14.  
  15. # make sure CDROM_ROOT envariable is set
  16.  
  17. if (! $?CDROM_ROOT) then
  18.     $DT_xconfirm notviewDT
  19.     exit 1
  20. endif
  21.  
  22. #
  23. # see if our server is running
  24. #
  25.  
  26. isServerRunning
  27.  
  28. if ($status == 1) then
  29.     $DT_xconfirm warn "Server is already running."
  30.     exit 2
  31. endif
  32.  
  33.  
  34. #
  35. # determine a reasonable tmp dir location 
  36. #
  37.  
  38. if ($?TMPDIR) then
  39.     set tmpDir = $TMPDIR
  40. else
  41.     if ( -e /tmp) then
  42.         set tmpDir = /tmp
  43.     else if ( -e /usr/tmp ) then 
  44.         set tmpDir = /usr/tmp
  45.     else 
  46.     $DT_xconfirm error "Directories /tmp and /usr/tmp are missing.\
  47.         Please set environment variable TMPDIR\
  48.         to be an alternate temp directory and retry."
  49.     exit 0
  50.     endif
  51. endif
  52.  
  53. #
  54. # find out the location of CDROM
  55. #
  56.  
  57. # inherited from CDROM_ROOT envariable
  58.  
  59. set dt_utilities = $HOME/$DT_WWW_ROOT/DT_utilities
  60. set htdocs = $HOME/$DT_WWW_ROOT/htdocs
  61. set conf = $HOME/$DT_WWW_ROOT/conf
  62. set logs = $HOME/$DT_WWW_ROOT/logs
  63. set cgi_bin = $HOME/$DT_WWW_ROOT/cgi-bin
  64. set icons = $HOME/$DT_WWW_ROOT/icons
  65. set DT_DocRootFile = $HOME/$DT_WWW_ROOT/.DT_DocRootFile
  66. set DT_OksvrRoot = $HOME/$DT_WWW_ROOT/.DT_OksvrRoot
  67. set dtcdresource = $HOME/$DT_WWW_ROOT/.dtcdresource
  68. set perm_dtcdres = $HOME/.dtcdresource
  69. set rm = /usr/bin/rm
  70.  
  71. #
  72. # now see if the www environment has been configured before
  73. # make sure the www environment is correctly conditioned
  74. #
  75.  
  76. # remove old DT_utilities link
  77. if ( -e $dt_utilities ) $rm -r $dt_utilities
  78. ln -s $DT_utilities $dt_utilities
  79. /usr/bin/mkdir -p $htdocs
  80.  
  81. # remove old htdocs files
  82. if ( -e $htdocs ) $rm -r $htdocs
  83. /usr/bin/mkdir -p $htdocs
  84.  
  85. # make dtcdresource, if necessary
  86.  
  87. # cd number set to -1 to force read of actual title
  88. touch $perm_dtcdres
  89. (echo "$htdocs\n$CDROM_ROOT/ -1"; grep -v $CDROM_ROOT $perm_dtcdres) > $dtcdresource
  90.  
  91. # clean old conf files
  92. if ( -e $conf ) $rm -r $conf
  93. /usr/bin/mkdir $conf
  94.  
  95. # remove old logs files
  96. if ( -e $HOME/$DT_WWW_ROOT/logs ) $rm -r $HOME/$DT_WWW_ROOT/logs
  97. /usr/bin/mkdir $HOME/$DT_WWW_ROOT/logs
  98. /usr/bin/chmod +w $HOME/$DT_WWW_ROOT/logs
  99.  
  100. # remove old links if any
  101.  
  102. #echo Cleaning up old links
  103. if ( -e $cgi_bin ) $rm -r $cgi_bin
  104. if ( -e $icons   ) $rm -r $icons
  105.  
  106. # remove .DT_* files
  107. if ( -e $DT_DocRootFile ) $rm $DT_DocRootFile
  108. if ( -e $DT_OksvrRoot )   $rm $DT_OksvrRoot
  109.  
  110. # create these files to set rw permissions
  111. /usr/bin/touch $HOME/$DT_WWW_ROOT/logs/{access_log,agent_log,error_log,referer_log}
  112.  
  113. /usr/bin/chmod +rw $HOME/$DT_WWW_ROOT/logs/{access_log,agent_log,error_log,referer_log}
  114.  
  115. #
  116. # set up new links - create "virtual document root"
  117. #
  118.  
  119.  
  120. #echo Setting up new links
  121.  
  122. set DTglobl   = "toolbox"
  123. set DTcdspace = "cdspace"
  124.  
  125. #$DT_utilities/linkChunks $htdocs $DTcdspace
  126. $CDROM_ROOT/bin/linkChunks $htdocs $DTcdspace
  127. set this_CD = `grep "id" $CDROM_ROOT/.IM | head -1 | sed -e 's/^[^"]*"//' -e 's/"[^"]*$//'`
  128.  
  129. pushd $htdocs >& /dev/null
  130. @ i = 0
  131. foreach n ($DT_BASE_CDs)
  132.     mkdir -p ext_cd$n/cd$i
  133.     /usr/bin/ln -s ext_cd$n cd$i
  134.     rm -rf ext_cd$n
  135.     @ i = $i + 1
  136. end
  137. LinkCdResource $htdocs "$HOME/$DT_WWW_ROOT" $this_CD
  138. #/usr/bin/ln -s $CDROM_ROOT                  ext_cd$this_CD
  139. /usr/bin/ln -s ext_cd$this_CD/toolbox       $DTglobl
  140. popd >& /dev/null
  141.  
  142. # files of augment directories override any corresponding files of main dir
  143. # however the need for such override should be small
  144.  
  145. # do directories which are tlinks, i.e. either/or files
  146. foreach subdir (cgi-bin icons)
  147.     if ($DT_NHLPERS > 0) then
  148.         foreach dir ($DT_HELPERS)
  149.             set d = $DT_utilities/$dir/$subdir
  150.             if (-d $d) $TLINK $d $HOME/$DT_WWW_ROOT/$subdir 
  151.         end
  152.     endif
  153.     $TLINK $DT_utilities/$subdir $HOME/$DT_WWW_ROOT/$subdir
  154. end
  155.  
  156. # do directories which are copies, i.e. concatenations from all sources
  157. foreach subdir (conf)
  158.     mkdir -p $HOME/$DT_WWW_ROOT/$subdir >& /dev/null
  159.     pushd $DT_utilities/$subdir >& /dev/null
  160.     foreach f (*)
  161.         cp $f $HOME/$DT_WWW_ROOT/$subdir
  162.     end
  163.     popd >& /dev/null
  164.     if ($DT_NHLPERS > 0) then
  165.         foreach dir ($DT_HELPERS)
  166.             if (! -d $DT_utilities/$dir/$subdir) continue
  167.             pushd $DT_utilities/$dir/$subdir >& /dev/null
  168.             foreach f (*)
  169.                 touch $HOME/$DT_WWW_ROOT/$subdir/$f
  170.                 cat $f >> $HOME/$DT_WWW_ROOT/$subdir/$f
  171.             end
  172.             popd >& /dev/null
  173.         end
  174.     endif
  175. end
  176.  
  177. /usr/bin/cp    $CDROM_ROOT/index.html $htdocs/.
  178. /usr/bin/ln -s $tmpDir                    $htdocs/tmp
  179. /usr/bin/cp $DT_utilities/dtCDmgr           $htdocs
  180.  
  181. #
  182. # this is essentially the ServerRoot
  183. #
  184.  
  185. set wwwRoot = $HOME/$DT_WWW_ROOT
  186.  
  187. #
  188. # create .DT_* files
  189. #
  190.  
  191. /usr/bin/touch $DT_DocRootFile
  192. echo \$DocumentRoot=\"$wwwRoot/htdocs\"  > $DT_DocRootFile
  193. chmod +rw $DT_DocRootFile
  194. /usr/bin/touch $DT_OksvrRoot
  195. echo \$OksvrSearchRoot=\"$wwwRoot/htdocs/toolbox/searchtools\"  > $DT_OksvrRoot
  196. chmod +rw $DT_OksvrRoot
  197.  
  198.  
  199. #
  200. # establish a free port number for the http server
  201. #
  202.  
  203. #
  204. # see if it is locked by someone else
  205. #
  206. while ( -e /tmp/.portlock ) 
  207.     echo "trying to obtain port number for http server, please wait"
  208.     sleep 1
  209. end
  210.  
  211. # lock the port number until the server actually starts
  212. /usr/bin/mkdir      /tmp/.portlock
  213. /usr/bin/chmod og-r /tmp/.portlock
  214.  
  215. set sockPort = `getFreePortNumber 8080`
  216.  
  217.  
  218. if ($sockPort == -1) then
  219.     $DT_xconfirm error "Could not find a free port for webserver."
  220.     exit 0
  221. endif
  222.  
  223. #
  224. # store it in a file
  225. #
  226. /usr/bin/touch $HOME/$DT_WWW_ROOT/logs/httpd.port
  227. echo $sockPort > $HOME/$DT_WWW_ROOT/logs/httpd.port
  228.  
  229. #
  230. # create a file in tmpDir which is port specific
  231. # we can store user home location, to be used by cgi-bin script
  232. #
  233.  
  234. #
  235. # note : have to rely on /tmp here ???
  236. #
  237. if (-e /tmp/.userhome_$sockPort) $rm -f /tmp/.userhome_$sockPort
  238. touch /tmp/.userhome_$sockPort
  239. echo \$userHome=\"$HOME\" > /tmp/.userhome_$sockPort
  240. /usr/bin/chmod +rw /tmp/.userhome_$sockPort
  241.  
  242. if (-e /tmp/.userhome_$CDROM_ROOT) $rm -f /tmp/.cdlocation_$sockPort
  243. touch /tmp/.cdlocation_$sockPort
  244. echo -n \$CDROM_ROOT=\"$CDROM_ROOT\" > /tmp/.cdlocation_$sockPort
  245. echo ";" >> /tmp/.cdlocation_$sockPort
  246. echo -n \$cdromMount=\"\$CDROM_ROOT\" >> /tmp/.cdlocation_$sockPort
  247. echo ";" >> /tmp/.cdlocation_$sockPort
  248. /usr/bin/chmod +rw /tmp/.cdlocation_$sockPort
  249.  
  250. #
  251. # at this point we have $DT_WWW_ROOT environment with right links
  252. #
  253. # create conf files
  254.  
  255. #
  256. # access.conf
  257. #
  258.  
  259. set accessConf = $conf/access.conf
  260. /usr/bin/touch $accessConf
  261. /usr/bin/chmod +rw $accessConf
  262.  
  263. echo "#                                  "  > $accessConf
  264. echo "<Directory $wwwRoot/cgi-bin>       " >> $accessConf
  265. echo "    Options Indexes FollowSymLinks " >> $accessConf
  266. echo "</Directory>                       " >> $accessConf
  267. echo "                                   " >> $accessConf
  268. echo "<Directory $wwwRoot/htdocs>        " >> $accessConf
  269. echo "    Options All                    " >> $accessConf
  270. echo "    AllowOverride All              " >> $accessConf
  271. echo "                                   " >> $accessConf
  272. echo "    <Limit GET>                    " >> $accessConf
  273. echo "        order allow,deny           " >> $accessConf
  274. echo "        allow from all             " >> $accessConf
  275. echo "    </Limit>                       " >> $accessConf
  276. echo "</Directory>                       " >> $accessConf
  277.  
  278. #
  279. # srm.conf
  280. #
  281.  
  282. set srmConf = $conf/srm.conf
  283. /usr/bin/touch $srmConf
  284. /usr/bin/chmod +rw $srmConf
  285.  
  286. echo \#                                                         > $srmConf
  287. echo DocumentRoot $wwwRoot/htdocs                              >> $srmConf
  288. echo                                                           >> $srmConf
  289. echo UserDir public_html                                       >> $srmConf
  290. echo                                                           >> $srmConf
  291. echo DirectoryIndex index.html                                 >> $srmConf
  292. echo                                                           >> $srmConf
  293. echo FancyIndexing on                                          >> $srmConf
  294. echo                                                           >> $srmConf
  295. echo AddIconByType \(TXT,/icons/text.xbm\) text/\*             >> $srmConf
  296. echo AddIconByType \(IMG,/icons/image.xbm\) image/\*           >> $srmConf
  297. echo AddIconByType \(SND,/icons/sound.xbm\) audio/\*           >> $srmConf
  298. echo AddIcon /icons/movie.xbm .mpg .qt                         >> $srmConf
  299. echo AddIcon /icons/binary.xbm .bin                            >> $srmConf
  300. echo                                                           >> $srmConf
  301. echo AddIcon /icons/back.xbm ..                                >> $srmConf
  302. echo AddIcon /icons/menu.xbm ^^DIRECTORY^^                     >> $srmConf
  303. echo AddIcon /icons/blank.xbm ^^BLANKICON^^                    >> $srmConf
  304. echo                                                           >> $srmConf
  305. echo DefaultIcon /icons/unknown.xbm                            >> $srmConf
  306. echo                                                           >> $srmConf
  307. echo ReadmeName README                                         >> $srmConf
  308. echo HeaderName HEADER                                         >> $srmConf
  309. echo                                                           >> $srmConf
  310. echo IndexIgnore \*/\.\?\?\* \*~ \*\# \*/HEADER\* \*/README\*  >> $srmConf
  311. echo                                                           >> $srmConf
  312. echo AccessFileName .htaccess                                  >> $srmConf
  313. echo                                                           >> $srmConf
  314. echo DefaultType text/plain                                    >> $srmConf
  315. echo                                                           >> $srmConf
  316. echo AddEncoding x-compress Z                                  >> $srmConf
  317. echo AddEncoding x-gzip gz                                     >> $srmConf
  318. echo                                                           >> $srmConf
  319. echo ScriptAlias /cgi-bin/ $wwwRoot/cgi-bin/                   >> $srmConf
  320. echo ScriptAlias /toolbox/www/cgi-bin/ $wwwRoot/cgi-bin/       >> $srmConf
  321. echo                                                           >> $srmConf
  322. echo AddType text/x-server-parsed-html .html                   >> $srmConf
  323. echo AddType text/x-server-parsed-html .shtml                  >> $srmConf
  324. echo AddType application/x-httpd-cgi .cgi                      >> $srmConf
  325. echo AddType application/x-httpd-cgi -cgi                      >> $srmConf
  326. echo AddType application/x-httpd-cgi .pl                       >> $srmConf
  327.  
  328.  
  329. if ($DT_domain == "") then
  330.     set mydomain = ""
  331. else
  332.     set mydomain = ".$DT_domain"
  333. endif
  334.  
  335. #
  336. # httpd.conf
  337. #
  338.  
  339. set httpdConf = $conf/httpd.conf
  340. /usr/bin/touch $httpdConf
  341. /usr/bin/chmod +rw $httpdConf
  342.  
  343. echo \#                                                         > $httpdConf
  344. echo ServerType standalone                                     >> $httpdConf
  345. echo                                                           >> $httpdConf
  346. echo Port $sockPort                                            >> $httpdConf
  347. echo                                                           >> $httpdConf
  348. echo User daemon                                               >> $httpdConf
  349. echo Group sys                                                 >> $httpdConf
  350. echo                                                           >> $httpdConf
  351. echo ServerAdmin @$DT_hostname$mydomain                        >> $httpdConf
  352. echo ServerName  $DT_hostname$mydomain                         >> $httpdConf
  353. echo                                                           >> $httpdConf
  354. echo ServerRoot $wwwRoot                                       >> $httpdConf
  355. echo                                                           >> $httpdConf
  356. echo ErrorLog logs/error_log                                   >> $httpdConf
  357. echo TransferLog logs/access_log                               >> $httpdConf
  358. echo AgentLog logs/agent_log                                   >> $httpdConf
  359. echo RefererLog logs/referer_log                               >> $httpdConf
  360. echo PidFile logs/httpd.pid                                    >> $httpdConf
  361.  
  362.  
  363. echo "httpd server:                    port $sockPort"
  364.  
  365. exit 1
  366.